<?php

/**
 * @author Thomas
 *
 */
class AbstractFitLogDataParser {

	function __construct() {

	}

	/**
	 * Load un return a DOMDocument from XML file
	 * @param string $pathToXmlFile
	 * @return DOMDocument
	 */
	public function loadXmlToDOMDocument($pathToXmlFile) {

		$doc = new DOMDocument();
		$doc->load($pathToXmlFile);
		return $doc;
	}

	/**
	 * Cast an object to another class, keeping the properties, but changing the methods
	 *
	 * @param string $class  Class name
	 * @param object $object
	 * @return object
	 */
	function cast($class, $object)
	{
		return unserialize(preg_replace('/^O:\d+:"[^"]++"/', 'O:' . strlen($class) . ':"' . $class . '"', serialize($object)));
	}

}

?>